//
//  FRMacros.h
//  FastRunning
//
//  Created by YANG on 2018/4/14.
//  Copyright © 2018年 HUA. All rights reserved.
//

#ifndef FRMacros_h
#define FRMacros_h

/**尺寸*/
#define MainScreen [UIScreen mainScreen].bounds

#define SCREEN_WIDTH [[UIScreen mainScreen] bounds].size.width

#define SCREEN_HEIGHT [[UIScreen mainScreen] bounds].size.height
#define SCREEN_SIZE [[UIScreen mainScreen] bounds].size

#define FRAME(x,y,w,h) CGRectMake(x, y, w, h)

#define maxX(a) CGRectGetMaxX(a)
#define maxY(a) CGRectGetMaxY(a)

#define minX(a) CGRectGetMidX(a)
#define minY(a) CGRectGetMinY(a)

/**字体大小*/
#define SYSTEMFONT(FONTSIZE)    [UIFont systemFontOfSize:FONTSIZE]

#define FONT(NAME, FONTSIZE)    [UIFont fontWithName:(NAME) size:(FONTSIZE)]

#define BOLDSYSTEMFONT(FONTSIZE)[UIFont boldSystemFontOfSize:FONTSIZE]

/**颜色*/
#define RGBA_Color(r,g,b,a) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]

//常规的16进制颜色
#define UIColorFromRGB(rgbValue)\
\
[UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
blue:((float)(rgbValue & 0xFF))/255.0 \
alpha:1.0]

//含透明度的16进制颜色
#define UIColorFromRGBA(rgbValue,a)\
\
[UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
blue:((float)(rgbValue & 0xFF))/255.0 \
alpha:a]

// 随机色
#define RandomColor ZXColor(arc4random_uniform(256), arc4random_uniform(256), arc4random_uniform(256))

/**当前版本*/
#define  App_Version  [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]


/** DEBUG LOG **/
#ifdef DEBUG
#define DLog(FORMAT, ...) fprintf(stderr,"%s:%d\t%s\n",[[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);
#else
#define DLog(FORMAT, ...) nil
#endif

/** 高度 */
#define STATUSBAR_HEIGHT [[UIApplication sharedApplication] statusBarFrame].size.height
#define STATUSBAR_WIDTH [[UIApplication sharedApplication] statusBarFrame].size.width
#define kMinRatio 2.0f / 3.0f

#define SAFE_AREA_INSETS ({UIEdgeInsets insets; if(@available(iOS 11.0, *)) {insets = UIApplication.sharedApplication.delegate.window.safeAreaInsets;} else {insets = UIEdgeInsetsZero;} insets;})

/** 机型 */
#define IPHONE4 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO)

#define IPHONE5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO)

#define IPHONE6 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(750, 1334), [[UIScreen mainScreen] currentMode].size) : NO)

#define IPHONE6PLUS ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2208), [[UIScreen mainScreen] currentMode].size) : NO)

#define IPHONEX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)

#endif /* FRMacros_h */
